package com.fuxue.controller.server;

import com.fuxue.dto.CommitDTO;
import com.fuxue.dto.ForumDTO;
import com.fuxue.dto.KnowledgeDTO;
import com.fuxue.dto.LikeDTO;
import com.fuxue.entity.Answer;
import com.fuxue.result.PageResult;
import com.fuxue.result.Result;
import com.fuxue.service.CommitService;
import com.fuxue.service.ForumService;
import com.fuxue.service.LikeService;
import com.fuxue.service.impl.ForumServiceImpl;
import com.fuxue.vo.ALLDetialsVO;
import com.fuxue.vo.KnowledgeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("serverForumController")
@RequestMapping("/users/server/forum")
@Slf4j
@Api(tags = "服务者论坛有关页面")
public class ForumController {
        @Autowired
        private ForumService forumService;
        /*
        问题查询
       */
        @GetMapping("/question")
        @ApiOperation("论坛问答贴分页查询")
        private Result<PageResult> AllCanSee( ForumDTO forumDTO)
        {
                log.info("论坛问答帖分页查询，参数为：{}",forumDTO);
                PageResult pageResult = forumService.pageQuery(forumDTO);
                return Result.success(pageResult);
        }
        /*
        添加知识帖
         */
        @PostMapping("/addTiez")
        @ApiOperation("服务者添加知识贴")
        private Result NewAnser(@RequestBody KnowledgeDTO knowledgeDTO)
        {
                log.info("论坛添加知识贴，参数为：{}",knowledgeDTO);
                forumService.InsertKnowledge(knowledgeDTO);
                return Result.success();
        }
        /*
        知识贴
        */
        @GetMapping("/answer")
        @ApiOperation("知识贴分页查询")
        private Result<PageResult> Answer(ForumDTO forumDTO)
        {
                log.info("知识贴分页查询，参数为：{}",forumDTO);
                PageResult pageResult = forumService.pageAnswerQuery(forumDTO);
                return Result.success(pageResult);
        }

        /*
        得到论坛的详细内容
         */
        @GetMapping("/allDetials")
        @ApiOperation("问答贴详情")
        private Result<ALLDetialsVO>GetAllDetials(@RequestParam Integer id)
        {
                log.info("问答贴详细内容，参数为：{}",id);
                ALLDetialsVO allDetialsVO = new ALLDetialsVO();
                allDetialsVO = forumService.getALL(id);
                return Result.success(allDetialsVO);
        }
        @GetMapping("/answerDetials")
        @ApiOperation("知识贴详情")
        private Result<KnowledgeVO>GetAnswerDetails(Integer answerId)
        {
                log.info("知识贴详情，参数为：{}",answerId);
                KnowledgeVO knowledgeVO = new KnowledgeVO();
                knowledgeVO = forumService.getKnowledge(answerId);
                return Result.success(knowledgeVO);
        }


}
